using System;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Collections.Generic;
using System.Reflection;

namespace Xdt.Archives.Data
{
  /// <summary>
  /// Warehouses Data Object Class
  /// </summary>
  public partial class DOWarehouses
  {
    #region Class Constant declarations
    		/// <summary>
		/// The Table Column for the Warehouses Warehouse
		/// </summary>
		public const string RowWarehouse = "Warehouse";


#region Stored Procedures
private const string m_StoredProcedureConstCreate = "spWarehouses_Create";
private const string m_StoredProcedureConstDelete = "spWarehouses_Delete";
private const string m_StoredProcedureConstRetrieve = "spWarehouses_Retrieve";
private const string m_StoredProcedureConstRetrieveall = "spWarehouses_Retrieveall";
private const string m_StoredProcedureConstUpdate = "spWarehouses_Update";
#endregion
    
    
    #endregion

    #region Class Variable declarations
    	#region DO Variables
		private string m_Warehouse;
	#endregion
    
	#region Default Variables
	private SQLDataObject sqlData;
	private List<DOWarehouses> m_Warehousess = new List<DOWarehouses>();
	#endregion
	
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Class Constructor
    /// </summary>
    public DOWarehouses() { }
    #endregion

    #region Class Properties
    #region DO Properties
		/// <summary>
		/// Warehouse
		/// </summary>
		/// <remarks>
		/// This property contains the Warehouses Warehouse
		/// </remarks>
		public string Warehouse
		{
			get { return (this.m_Warehouse); }
			set { this.m_Warehouse = value; }
		}
		#endregion
    
	#region Default Properties
	public List<DOWarehouses> Warehousess
	{
	  get { return m_Warehousess; }
	  set { m_Warehousess = value; }
	}    
	#endregion
	
    #endregion

    #region Class Methods
    public bool Retrieve()
    {
      sqlData = new SQLDataObject();
      DataSet resultDS = sqlData.ExecuteDataSetSQL(m_StoredProcedureConstRetrieve + " @" + RowWarehouse + "=" + this.Warehouse);
      return SetClassPropertiesFromDataSet(resultDS);
    }

    public bool RetrieveAll()
    {
      sqlData = new SQLDataObject();
      string sVariables = sqlData.GetVariables(this);

      DataSet resultDS = sqlData.ExecuteDataSetSQL(m_StoredProcedureConstRetrieveall + " " + sVariables);
      return SetClassPropertiesListFromDataSet(resultDS);
    }

    public bool Create()
    {
      bool success = false;
      sqlData = new SQLDataObject();
      string sVariables = sqlData.GetVariables(this);

      success = sqlData.ExecuteNonQuerySQL(m_StoredProcedureConstCreate + " " + sVariables);

      return success;
    }

    public bool Update()
    {
      bool success = false;
      sqlData = new SQLDataObject();

      string sVariables = sqlData.GetVariables(this);

      success = sqlData.ExecuteNonQuerySQL(m_StoredProcedureConstUpdate + " " + sVariables);

      return success;
    }

    private bool SetClassPropertiesFromDataSet(DataSet resultDS)
    {
      bool success = false;
      if (resultDS.Tables[0] != null)
      {
        if (resultDS.Tables[0].Rows.Count > 0)
        {
          foreach (DataRow dr in resultDS.Tables[0].Rows)
          {
					if (dr[RowWarehouse].ToString() != "")
			this.Warehouse = dr[RowWarehouse].ToString();
          }
          success = true;
        }
      }
      return success;
    }

    private bool SetClassPropertiesListFromDataSet(DataSet resultDS)
    {
      bool success = false;
      if (resultDS.Tables[0] != null)
      {
        if (resultDS.Tables[0].Rows.Count > 0)
        {
          foreach (DataRow dr in resultDS.Tables[0].Rows)
          {
            DOWarehouses Warehouses = new DOWarehouses();
			
					if (dr[RowWarehouse].ToString() != "")
			Warehouses.Warehouse = dr[RowWarehouse].ToString();

            this.Warehousess.Add(Warehouses);
          }
          success = true;
        }
      }
      return success;
    }
    #endregion

    #region Class Support Methods
    #endregion
  }
}
